<?php

namespace app\common\validate;

use app\admin\validate\Admin;
use think\Validate;

class AdminValidate extends Validate
{
    protected $rule = [
        'username' => 'require|min:3|max:20|unique:admin',
        'mobile' => 'require|mobile|unique:admin',
        'email' => 'email|unique:admin',
        'role_id' => 'require',
        'password' => 'requireWithout:id|min:8|max:16|regex:/(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\W_]).{8,16}/',
        'confirmPassword' => 'require|confirm:password',
    ];


    protected $field = [
        'username' => '用户名',
        'mobile' => '手机号',
        'email' => '邮箱',
        'password' => '密码',
        'checkPassword' => '密码不能为空',
        'confirmPassword' => '确认密码',
        'role_id' => '角色',
    ];

    protected $scene = [
        'add' => ['username','mobile','email','password','confirmPassword','role_id'],
        'edit' => ['mobile','email','password','confirmPassword','role_id'],
    ];

}